/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.evl.tecinfo.gui;

import br.com.evl.tecinfo.modelo.ApenasLetrasMinusculas;
import br.com.evl.tecinfo.modelo.Usuario;
import java.awt.Color;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author Tecinfo
 */
public class LoginUsuario extends javax.swing.JFrame {

    private int clicou_ok;
    private int linha_editar = -1;

    /**
     * Creates new form loginusuario
     */
    public LoginUsuario() {
        initComponents();
        setSize(380, 320);
        setLocationRelativeTo(this);
        setTitle("Login Usuário");





        //LIMITANDO CARACTERES DO FORMULÁRIO
        //JTextField textFieldLogin = new JTextField();
        jFormattedTextField_Login.setDocument(new ApenasLetrasMinusculas(20));


    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelLoginUsuario = new javax.swing.JLabel();
        jLabellogin_nome = new javax.swing.JLabel();
        jLabelsenha = new javax.swing.JLabel();
        jFormattedTextField_Login = new javax.swing.JFormattedTextField();
        jPasswordFieldSennhaLigon = new javax.swing.JPasswordField();
        jButton1_conectarlogin = new javax.swing.JButton();
        jButtoncancelarlogin = new javax.swing.JButton();
        jLabelIMGlogoLogin = new javax.swing.JLabel();
        jLabelIMGLoginUsuario = new javax.swing.JLabel();
        jLabelIMGbg = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        getContentPane().setLayout(null);

        jLabelLoginUsuario.setFont(new java.awt.Font("Century Gothic", 0, 15)); // NOI18N
        jLabelLoginUsuario.setText("LOGIN DO USUÁRIO");
        getContentPane().add(jLabelLoginUsuario);
        jLabelLoginUsuario.setBounds(150, 50, 160, 30);

        jLabellogin_nome.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabellogin_nome.setText("Login:");
        getContentPane().add(jLabellogin_nome);
        jLabellogin_nome.setBounds(40, 130, 50, 30);

        jLabelsenha.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jLabelsenha.setText("Senha:");
        getContentPane().add(jLabelsenha);
        jLabelsenha.setBounds(40, 170, 40, 30);
        getContentPane().add(jFormattedTextField_Login);
        jFormattedTextField_Login.setBounds(100, 130, 220, 30);

        jPasswordFieldSennhaLigon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordFieldSennhaLigonActionPerformed(evt);
            }
        });
        getContentPane().add(jPasswordFieldSennhaLigon);
        jPasswordFieldSennhaLigon.setBounds(100, 170, 220, 30);

        jButton1_conectarlogin.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jButton1_conectarlogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/evl/tecinfo/gui/imagens/conformado20x20.png"))); // NOI18N
        jButton1_conectarlogin.setText("CONECTAR");
        jButton1_conectarlogin.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButton1_conectarlogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1_conectarloginActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1_conectarlogin);
        jButton1_conectarlogin.setBounds(60, 230, 120, 30);

        jButtoncancelarlogin.setFont(new java.awt.Font("Century Gothic", 0, 12)); // NOI18N
        jButtoncancelarlogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/evl/tecinfo/gui/imagens/sair20x20.png"))); // NOI18N
        jButtoncancelarlogin.setText("CANCELAR");
        jButtoncancelarlogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtoncancelarloginActionPerformed(evt);
            }
        });
        getContentPane().add(jButtoncancelarlogin);
        jButtoncancelarlogin.setBounds(200, 230, 120, 30);

        jLabelIMGlogoLogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/evl/tecinfo/gui/imagens/login.png"))); // NOI18N
        getContentPane().add(jLabelIMGlogoLogin);
        jLabelIMGlogoLogin.setBounds(40, 20, 70, 80);

        jLabelIMGLoginUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/evl/tecinfo/gui/imagens/CADASTRODEUSUARIO.png"))); // NOI18N
        getContentPane().add(jLabelIMGLoginUsuario);
        jLabelIMGLoginUsuario.setBounds(130, 40, 210, 50);

        jLabelIMGbg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/evl/tecinfo/gui/imagens/backgroud.jpg"))); // NOI18N
        getContentPane().add(jLabelIMGbg);
        jLabelIMGbg.setBounds(-6, -6, 390, 320);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1_conectarloginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1_conectarloginActionPerformed

        ArrayList<Usuario> logins = new ArrayList<>();
        Usuario login = new Usuario();
        login.setLogin(jFormattedTextField_Login.getText());
        login.setSenha(jPasswordFieldSennhaLigon.getText());



        boolean nomevazio = false;
        boolean senhavazio = false;

        if (linha_editar == -1) {
            if (jFormattedTextField_Login.getText().equals("")) {
                nomevazio = true;
            } else {
                nomevazio = false;
            }
            if (jPasswordFieldSennhaLigon.getPassword().length == 0) {
                senhavazio = true;
            } else {
                senhavazio = false;
            }
            //LOGICA PARA MANDA MENSAGEM DE ERRO (EXISTE CAMPOS VAZIOS)
            if (nomevazio == true || senhavazio == true) {
                java.awt.Toolkit.getDefaultToolkit().beep();
                JOptionPane.showMessageDialog(null, "LOGIN INCORRETO!");
                jFormattedTextField_Login.setText("");
                jPasswordFieldSennhaLigon.setText("");
            } else if (nomevazio == false && senhavazio == false) {
                //CHECAR SE A SENHA É VÁLIDA
            }

        }

    }//GEN-LAST:event_jButton1_conectarloginActionPerformed

    private void jPasswordFieldSennhaLigonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordFieldSennhaLigonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPasswordFieldSennhaLigonActionPerformed

    private void jButtoncancelarloginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoncancelarloginActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtoncancelarloginActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(LoginUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LoginUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LoginUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LoginUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LoginUsuario().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1_conectarlogin;
    private javax.swing.JButton jButtoncancelarlogin;
    private javax.swing.JFormattedTextField jFormattedTextField_Login;
    private javax.swing.JLabel jLabelIMGLoginUsuario;
    private javax.swing.JLabel jLabelIMGbg;
    private javax.swing.JLabel jLabelIMGlogoLogin;
    private javax.swing.JLabel jLabelLoginUsuario;
    private javax.swing.JLabel jLabellogin_nome;
    private javax.swing.JLabel jLabelsenha;
    private javax.swing.JPasswordField jPasswordFieldSennhaLigon;
    // End of variables declaration//GEN-END:variables
}
